(function(){
$id = function (a) {
    return document.getElementById(a)
};
var inv = new Object();
inv.bind = function (c, a, b) {
    if (c.addEventListener) {
        c.addEventListener(a, b, false)
    } else {
        if (c.attachEvent) {
            c.attachEvent("on" + a, b)
        } else {
            c["on" + a] = b
        }
    }
};
inv.stopProp = function (a) {
    var a = a || window.event;
    a.stopPropagation ? a.stopPropagation() : (a.cancelBubble = true)
};

function screenCutPic() {
    var k = $(""), p = $id("detailPicBox"), g = $id("detailPicPrev"), c = $id("detailPicNext");
    var h, f, r, o, e, j, m;
    var b, n, q, a = $id("detailDrag");
    e = p.offsetWidth;
    q = a.offsetLeft;
    l(k[h]);
    function l(i, s) {
        r = "<dd>";
        a.style.display = "none";
        o = $(p).find("dd");
        o[0].style.width = "40000px";
        $("#detailPicBox img:last")[0].onload = function () {
            j = 0, m = 0;
            newObj = o[0].getElementsByTagName("img");
            for (h = 0; h < newObj.length; h++) {
                j = newObj[h].height > j ? newObj[h].height : j;
                m += newObj[h].offsetWidth + 20
            }
            m -= 10;
            p.style.height = j + "px";
            o[0].style.width = m + "px";
            p.scrollLeft = 0;
			 a.style.display = "block";
            if (p.scrollWidth != p.offsetWidth) {
                a.style.display = "block";
                a.style.left = (423 * p.scrollLeft / (p.scrollWidth - p.offsetWidth) + 1) + "px"
            }
        }
    }

    k.click(function () {
        var i = this.innerHTML.replace(/\s{1,}$/, "");
        k[0].parentNode.className = k[0].parentNode.className.replace(" ipad", "");
        if (i == "iPad") {
            k[0].parentNode.className += " ipad"
        }
        l(this)
    });
    inv.bind(p, "mousewheel", d);
    inv.bind(p, "DOMMouseScroll", d);
    function d(s) {
        var s = s || window.event, i;
        s.stopPropagation && (s.preventDefault(), s.stopPropagation()) || (s.cancelBubble = true, s.returnValue = false);
        if (s.wheelDelta) {
            i = s.wheelDelta / 120
        } else {
            if (s.detail) {
                i = -s.detail / 3
            }
        }
        if (p.scrollWidth == p.offsetWidth) {
            return
        }
        i > 0 ? p.scrollLeft -= 70 : p.scrollLeft += 70;
        a.style.left = (423 * p.scrollLeft / (p.scrollWidth - p.offsetWidth) + 1) + "px"
    }
    a.ondragstart = function () {
        return false
    };
    a.onmousedown = function (s) {
        var i = this, s = s || window.event;
        n = s.clientX - i.offsetLeft;
        document.onmousemove = function (t) {
            var t = t || window.event;
            b = t.clientX - n - q;
            if (b < 1) {
                b = 1
            }
            if (b > 424) {
                b = 424
            }
            a.style.left = b + "px";
            p.scrollLeft = b / 424 * (m - e)
        };
        document.onmouseup = function () {
            this.onmousemove = null
        }
    }
}
//$(document).ready(function () {
    screenCutPic();
//});
})();